# RUN: llc -mtriple powerpc64-unknown-linux-gnu -run-pass=ppc-expand-isel -o \
# RUN:   - %s -verify-machineinstrs | FileCheck %s

---
name:           expand_isel_liveness1
tracksRegLiveness: true
registers:       []
liveins:
  - { reg: '$x3', virtual-reg: '' }
  - { reg: '$x4', virtual-reg: '' }
  - { reg: '$x5', virtual-reg: '' }
  - { reg: '$x6', virtual-reg: '' }
body:             |
  bb.0:
    liveins: $x3, $x4, $x5, $x6
  
    renamable $x8 = MULLD renamable $x5, renamable $x4
    renamable $cr5 = CMPDI renamable $x3, 0
    dead renamable $x9 = MULHDU_rec renamable $x3, renamable $x6, implicit-def $cr0
    renamable $x3 = MULLD killed renamable $x3, renamable $x6
    $cr1 = MCRF killed $cr0
    renamable $x3 = ADD8 killed renamable $x3, killed renamable $x8
    renamable $cr0 = CMPDI renamable $x5, 0
    renamable $cr5lt = CRNOR killed renamable $cr0eq, killed renamable $cr5eq, implicit $cr5, implicit $cr0
    renamable $cr0 = CMPLDI renamable $x3, 0
    renamable $x8 = MULHDU renamable $x4, renamable $x6
    renamable $x3 = ADD8 renamable $x8, killed renamable $x3
    renamable $cr6 = CMPLD renamable $x3, killed renamable $x8
    renamable $cr5gt = CRANDC killed renamable $cr6lt, killed renamable $cr0eq, implicit $cr0, implicit $cr6
    renamable $cr5lt = CRORC killed renamable $cr5lt, killed renamable $cr1eq, implicit $cr1
    renamable $x7 = LI8 1
    dead renamable $x5 = MULHDU_rec killed renamable $x5, renamable $x4, implicit-def $cr0
    renamable $cr5lt = CRORC killed renamable $cr5lt, killed renamable $cr0eq, implicit $cr0
    renamable $cr5lt = CRNOR killed renamable $cr5lt, killed renamable $cr5gt
    renamable $x4 = MULLD killed renamable $x4, killed renamable $x6
    renamable $x5 = ISEL8 $zero8, killed renamable $x7, killed renamable $cr5lt
    BLR8 implicit $lr8, implicit $rm, implicit killed $x3, implicit killed $x4, implicit killed $x5

  ; CHECK-LABEL: name: expand_isel_liveness1
  ; CHECK: bb.1:
  ; CHECK:   liveins: $x3, $x4, $x7
  ; CHECK:   renamable $x5 = ORI8 killed renamable $x7, 0
  ; CHECK:   B %bb.3
  ; CHECK: bb.2:
  ; CHECK:   liveins: $x3, $x4
  ; CHECK:   renamable $x5 = ADDI8 $zero8, 0
  ; CHECK: bb.3:
  ; CHECK:   liveins: $x3, $x4, $x5
  ; CHECK:   BLR8 implicit $lr8, implicit $rm, implicit killed $x3, implicit killed $x4, implicit killed $x5
...

---
name:            expand_isel_liveness2
tracksRegLiveness: true
liveins:
  - { reg: '$r0' }
  - { reg: '$r3' }
body:             |
  bb.0.entry:
    liveins: $r0, $r3

    $r5 = ADDI $r3, 1
    $cr0 = CMPWI $r3, 0
    $r3 = ISEL $zero, killed $r0, killed $cr0gt

  ; CHECK-LABEL: name: expand_isel_liveness2
  ; CHECK: bb.0.entry:
  ; CHECK:   liveins: $r0, $r3
  ; CHECK:   $r5 = ADDI $r3, 1
  ; CHECK:   $cr0 = CMPWI $r3, 0
  ; CHECK:   BC killed $cr0gt, %bb.2
  ; CHECK: bb.1.entry:
  ; CHECK:   liveins: $r0
  ; CHECK:   $r3 = ORI killed $r0, 0
  ; CHECK:   B %bb.3
  ; CHECK: bb.2.entry:
  ; CHECK-NOT:   liveins: $zero
  ; CHECK:   $r3 = ADDI $zero, 0
...

